
import { getStorage, setStorage, removeStorage } from '@/utils/storage';
import { getCos } from '@/api/cos';
const state = {
	cos_info: getStorage('cos_info') ? JSON.parse(getStorage('cos_info')) : null,
}
const mutations = {
	CACHE_COS: (state, data) => {
		state.cos_info = data
		setStorage('cos_info', JSON.stringify(data), 1800)
	}
}
const actions = {
	cosInfo ({ commit, state }) {
		// 
		return new Promise((resolve, reject) => {
			getCos().then(response => {
				commit('CACHE_COS', response)
				resolve(response)
			}).catch(error => {
				reject(error)
			})
		})

	}
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
}
